package com.ruoyi.knowledge.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.knowledge.topicfollow.domain.TopicFollow;
import com.ruoyi.knowledge.topicfollow.service.ITopicFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 话题关注管理Controller
 * 
 * @author Jm
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/topicfollow/topicfollow")
public class TopicFollowController extends BaseController
{
    @Autowired
    private ITopicFollowService topicFollowService;

    /**
     * 查询话题关注管理列表
     */
    @PreAuthorize("@ss.hasPermi('topicfollow:topicfollow:list')")
    @GetMapping("/list")
    public TableDataInfo list(TopicFollow topicFollow)
    {
        startPage();
        List<TopicFollow> list = topicFollowService.selectTopicFollowList(topicFollow);
        return getDataTable(list);
    }

    /**
     * 导出话题关注管理列表
     */
    @PreAuthorize("@ss.hasPermi('topicfollow:topicfollow:export')")
    @Log(title = "话题关注管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TopicFollow topicFollow)
    {
        List<TopicFollow> list = topicFollowService.selectTopicFollowList(topicFollow);
        ExcelUtil<TopicFollow> util = new ExcelUtil<TopicFollow>(TopicFollow.class);
        util.exportExcel(response, list, "话题关注管理数据");
    }

    /**
     * 获取话题关注管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('topicfollow:topicfollow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(topicFollowService.selectTopicFollowById(id));
    }

    /**
     * 新增话题关注管理
     */
    @PreAuthorize("@ss.hasPermi('topicfollow:topicfollow:add')")
    @Log(title = "话题关注管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TopicFollow topicFollow)
    {
        return toAjax(topicFollowService.insertTopicFollow(topicFollow));
    }

    /**
     * 修改话题关注管理
     */
    @PreAuthorize("@ss.hasPermi('topicfollow:topicfollow:edit')")
    @Log(title = "话题关注管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TopicFollow topicFollow)
    {
        return toAjax(topicFollowService.updateTopicFollow(topicFollow));
    }

    /**
     * 删除话题关注管理
     */
    @PreAuthorize("@ss.hasPermi('topicfollow:topicfollow:remove')")
    @Log(title = "话题关注管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(topicFollowService.deleteTopicFollowByIds(ids));
    }
}